package com.icourt.learn.steam;


import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;

import java.util.stream.Stream;

/**
 * 无限流测试 100次调用产生的结果集在Stram中
 */
@Slf4j
public class Generate {

    @Test
    public  void test(){

        Stream<Double> stream=Stream.generate(Generate::getDouble).limit( 100 );


        Stream newStream=Stream.concat( stream,Stream.generate( Math::random ).peek( e->log.debug( "升恒：{}",e )   ).limit( 100 ).peek( e->log.debug( "结果：{}",e )   ).sorted() );
        newStream.forEach( e->{log.debug( "值{}",e );} );
    }


    static double getDouble(){
        return 1.0d;
    }

    static double getDouble2(){
        return 2.0d;
    }
}
